﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PokeTD
{
    class TowerEffectBurn : TowerEffect
    {
        static Texture2D EffectTexture = null;
        float damageTimer = 0;

        public TowerEffectBurn(float lifeTime, Creep creep)
            : base(lifeTime, creep)
        {
            if (EffectTexture == null)
                EffectTexture = Globals.Content.Load<Texture2D>("MiscGfx/tower_burn");

            for (int i = 0; i < Random.Next(15, 35); i++)
            {
                int x = Random.Next(-20, 20);
                int y = Random.Next(-20, 20);
                int vx = Random.Next(-6, 6);
                int vy = Random.Next(-6, 6);
                Particles.Add(new TowerEffectParticle(new Vector2(x + 16, y + 16), new Vector2(vx, vy), lifeTime, EffectTexture, creep));
            }
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (Alive)
            {
                damageTimer -= (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (damageTimer <= 0.0f)
                {
                    Creep.HP -= Creep.HP / 20;
                    damageTimer = 1.0f;
                }
            }
        }

        public override void Draw(SpriteBatch spriteBatch, Vector2 renderRoot)
        {
            base.Draw(spriteBatch, renderRoot);
        }
    }
}
